import React, { Component } from 'react'
import {NavLink} from 'react-router-dom'

export default class GoodsList extends Component {
  constructor() {
    super();
    this.state = {
      goodsList: [
        {name: 'mi 11', price: 6999},
        {name: 'iphone 12', price: 5999},
        {name: 'huawei P40', price: 4999},
      ]
    }
  }
  render() {
    let liDom = this.state.goodsList.map(item => {
      return <li key={item.name}><NavLink to={'/goodsdetail/'+item.name}>{item.name}--￥{item.price}</NavLink></li>
    })
    return (
      <div>
        <ul>
          {liDom}
        </ul>
      </div>
    )
  }
}
